package org.apm.data.bean;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;

public enum DataType {
    JavaTraceData("JavaTraceData", "DefaultMessage.startTime", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    JavaManagementData("JavaManagementData", "jManagementMessage.creationTime", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    JvmProperties("JvmProperties", "jManagementMessage.creationTime", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    HttpData("HttpData", "timestamp", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    SnifferData("SnifferData", "timestamp", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    RelationShip("RelationShip", "timestamp", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    Response("Response", "timestamp", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    DBType("DBType", "timestamp", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    View("View", "timestamp", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    EventWaiting("EventWaiting", "createTime", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")),
    pagemonitor("pagemonitor", "navigationStart", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS")),
    mouseclick("mouseclick", "clickTime", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS")),
    Sessions("Sessions", "startTime", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS")),
    SnifferSql("SnifferSql", "", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS")),
    resourcesmonitor("resourcesmonitor", "", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS")),
    Event("Event", "", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS")),
    Keyup("keyup", "indexTime", ISODateTimeFormat.dateHourMinuteSecond()),
    Input("input", "indexTime", ISODateTimeFormat.dateHourMinuteSecond()),
    Unknown("Unknown", "", null);

    public final String type;
    public final String timeField;
    public final DateTimeFormatter timeFormatter;

    DataType(final String type, final String timeField, final DateTimeFormatter dateTimeFormatter) {
        this.type = type;
        this.timeField = timeField;
        this.timeFormatter = dateTimeFormatter;
    }

    public static DataType dataType(String type) {
        for (DataType dataType : DataType.values()) {
            if (dataType.type.equals(type)) {
                return dataType;
            }
        }
        return Unknown;
    }
    
    public static void main(String[] args) {
        System.out.println(new DateTime().toString(ISODateTimeFormat.dateHourMinuteSecond()));
    }
}
